<template>
    <div class="template-form-Lu">
        <a-modal
            title="网站信息发布审批"
            :visible="applicationFormVisible"
            :maskClosable="false"
            :closable="true"
            :destroyOnClose="true"
            width="100%"
            :dialog-style="{ margin: '0 auto' }"
            wrapClassName="applicationModal-form-fullmodal-Lu"
            @cancel="closeVisible">
            <div class="applicationModal-div-box-Lu">
                <div class="tabs-card-edit-box">
                    <a-tabs type="card" v-model:activeKey="summaryActiveKey" @change="summaryActiveChange">
                        <a-tab-pane key="申请表" tab="申请表"></a-tab-pane>
                        <a-tab-pane key="流转记录" tab="流转记录"></a-tab-pane>
                    </a-tabs>
                </div>
                <div  class="tab-box-v1">
                    <div v-if="summaryActiveKey == '申请表'" style="width: 70%;margin: 0 auto;padding-top: 30px;padding-bottom: 30px;">
                        <a-spin :spinning="spinning">
                            <a-button class="blue-btn" @click="printClick('宣传',formState,qmImgList)" v-if="linkName == '我的已办'">打印</a-button>
                            <a-form :form="aform" ref="form" class="internalControl-reimbursement-model-form-box">
                                <a-descriptions bordered style="width: 100%;">
                                    <a-descriptions-item :span="2">
                                        <span slot="label" class="descriptions-label-slot">
                                            <span class="xhText" v-if="linkName =='申请'">*</span>
                                            信息名称
                                        </span>
                                        <a-form-item ref="fxxmc" prop="fxxmc" class="zm-form-model">
                                            <a-textarea
                                                v-if="linkName=='申请' || linkName == '数据修订'"
                                                v-model="formState.fxxmc"
                                                placeholder="请输入信息名称:"
                                                :auto-size="{ minRows: 2}"
                                                v-decorator="[
                                                    'fxxmc', {initialValue:formState.fxxmc,rules: rules.fxxmc}]"
                                            />
                                            <span v-else>{{ formState.fxxmc }}</span>
                                        </a-form-item>
                                    </a-descriptions-item>
                                    <a-descriptions-item :span="3">
                                        <span slot="label" class="descriptions-label-slot">
                                            <span class="xhText" v-if="linkName=='申请'">*</span>
                                            发布栏目
                                        </span>
                                        <a-form-item ref="ffblm" prop="ffblm" class="zm-form-model">
                                            <a-textarea
                                                v-if="linkName=='申请' || linkName == '数据修订'"
                                                v-model="formState.ffblm"
                                                placeholder="请输入发布栏目:"
                                                :auto-size="{ minRows: 2}"
                                                v-decorator="[
                                                    'ffblm', {initialValue:formState.ffblm,rules: rules.ffblm}]"
                                            />
                                            <span v-else>{{ formState.ffblm }}</span>
                                        </a-form-item>
                                    </a-descriptions-item>
                                    <a-descriptions-item :span="3">
                                        <span slot="label" class="descriptions-label-slot">
                                            附&emsp;&emsp;件
                                        </span>
                                        <a-form-item ref="fnbyj" prop="fnbyj" class="zm-form-model">
                                            <uploadFilesList :config="uploadFilesListConfig" @emitFormid="emitFormid" :filesFormState="{...formState}"/>
                                        </a-form-item>
                                    </a-descriptions-item>
                                    <a-descriptions-item :span="3">
                                        <span slot="label" class="descriptions-label-slot">
                                            文本编辑
                                        </span>
                                        <a-form-item ref="flmnr" prop="flmnr" class="zm-form-model">
                                            <div v-if="linkName == '申请'">
                                                <quill-editor v-model:value="formState.flmnr"></quill-editor>
                                            </div>
                                            <div v-else v-html="formState.flmnr"></div>
                                        </a-form-item>
                                    </a-descriptions-item>
                                    <a-descriptions-item :span="3" v-if="descriptionsData('科室审批').hjmc">
                                        <span slot="label" class="descriptions-label-slot">
                                            <span class="xhText" v-if="linkName == descriptionsData('科室审批').hjmc">*</span>
                                            科室领导意见
                                        </span>
                                        <a-form-item ref="fngksyj" prop="fngksyj" class="zm-form-model">
                                            <div style="width: 100%;" v-if="(descriptionsData('科室审批').blzt == '待办' && linkName!=='我的已办') || linkName == '数据修订'">
                                                <reviewOpinions
                                                    ref="reviewOpinionsReffngksyj"
                                                    @getInputOpinion="getInputOpinion"
                                                    @openOpinions="opinions('宣传信息审批',formState.fngksyj,'fngksyj')"
                                                    v-decorator="[
                                                        'fngksyj', { initialValue:formState.fngksyj, rules: rules.fngksyj}
                                                ]"/>
                                                <div  v-if="linkName == '数据修订'" style="text-align: right;">
                                                    <span>办理时间：</span>
                                                    <a-date-picker
                                                        show-time
                                                        :v-model="moment(formState.fksfzrqmsj)"
                                                        :default-value="moment(formState.fksfzrqmsj)"
                                                        :allowClear="false"
                                                        @change="yjTimeChange($event,'fksfzrqmsj')"
                                                    />
                                                </div>
                                            </div>
                                            <div style="width: 100%;" v-else>
                                                <p>{{ formState.fngksyj }}</p>
                                                <div class="yjqm-right-bottom">
                                                    <img v-if="getUrl('科室审批')" :src="getUrl('科室审批')" alt="" class="yjqmImg"/>
                                                    <span v-else class="yjqmImg">{{ formState.fksfzr }}</span>
                                                    <span>{{ formState.fksfzrsj }}</span>
                                                </div>
                                            </div>
                                        </a-form-item>
                                    </a-descriptions-item>
                                    <a-descriptions-item :span="3" v-if="descriptionsData('办公室审批').hjmc">
                                        <span slot="label" class="descriptions-label-slot">
                                            <span class="xhText" v-if="linkName == descriptionsData('办公室审批').hjmc">*</span>
                                            办公室审批
                                        </span>
                                        <a-form-item ref="fbgsyj" prop="fbgsyj" class="zm-form-model">
                                            <div style="width: 100%;" v-if="(descriptionsData('办公室审批').blzt == '待办' && linkName!=='我的已办') || linkName == '数据修订'">
                                                <reviewOpinions
                                                    ref="reviewOpinionsReffbgsyj"
                                                    @getInputOpinion="getInputOpinion"
                                                    @openOpinions="opinions('宣传信息审批',formState.fbgsyj,'fbgsyj')"
                                                    v-decorator="[
                                                        'fbgsyj', { initialValue:formState.fbgsyj, rules: rules.fbgsyj}
                                                ]"/>
                                                <div  v-if="linkName == '数据修订'" style="text-align: right;">
                                                    <span>办理时间：</span>
                                                    <a-date-picker
                                                        show-time
                                                        :v-model="moment(formState.fksfzrqmsj)"
                                                        :default-value="moment(formState.fksfzrqmsj)"
                                                        :allowClear="false"
                                                        @change="yjTimeChange($event,'fksfzrqmsj')"
                                                    />
                                                </div>
                                            </div>
                                            <div style="width: 100%;" v-else>
                                                <p>{{ formState.fbgsyj }}</p>
                                                <div class="yjqm-right-bottom">
                                                    <img v-if="getUrl('办公室审批')" :src="getUrl('办公室审批')" alt="" class="yjqmImg"/>
                                                    <span v-else class="yjqmImg">{{ formState.fbgsfzr }}</span>
                                                    <span>{{ formState.fbgsfzrsj }}</span>
                                                </div>
                                            </div>
                                        </a-form-item>
                                    </a-descriptions-item>
                                    <a-descriptions-item :span="3" v-if="descriptionsData('中心分管领导审批').hjmc">
                                        <span slot="label" class="descriptions-label-slot">
                                            <span class="xhText" v-if="linkName == descriptionsData('中心分管领导审批').hjmc">*</span>
                                            中心分管领导意见
                                        </span>
                                        <a-form-item ref="fngksyj" prop="fngksyj" class="zm-form-model">
                                            <div style="width: 100%;" v-if="(descriptionsData('中心分管领导审批').blzt == '待办' && linkName!=='我的已办') || linkName == '数据修订'">
                                                <reviewOpinions
                                                    ref="reviewOpinionsReffzxfgldspyj"
                                                    @getInputOpinion="getInputOpinion"
                                                    @openOpinions="opinions('宣传信息审批',formState.fzxfgldspyj,'fzxfgldspyj')"
                                                    v-decorator="[
                                                        'fzxfgldspyj', { initialValue:formState.fzxfgldspyj, rules: rules.fzxfgldspyj}
                                                ]"/>
                                                <div  v-if="linkName == '数据修订'" style="text-align: right;">
                                                    <span>办理时间：</span>
                                                    <a-date-picker
                                                        show-time
                                                        :v-model="moment(formState.fksfzrqmsj)"
                                                        :default-value="moment(formState.fksfzrqmsj)"
                                                        :allowClear="false"
                                                        @change="yjTimeChange($event,'fksfzrqmsj')"
                                                    />
                                                </div>
                                            </div>
                                            <div style="width: 100%;" v-else>
                                                <p>{{ formState.fzxfgldspyj }}</p>
                                                <div class="yjqm-right-bottom">
                                                    <img v-if="getUrl('中心分管领导审批')" :src="getUrl('中心分管领导审批')" alt="" class="yjqmImg"/>
                                                    <span v-else class="yjqmImg">{{ formState.fzxfgldr }}</span>
                                                    <span>{{ formState.fzxfgldrsj }}</span>
                                                </div>
                                            </div>
                                        </a-form-item>
                                    </a-descriptions-item>
                                    <a-descriptions-item :span="3" v-if="descriptionsData('中心主任审批').hjmc">
                                        <span slot="label" class="descriptions-label-slot">
                                            <span class="xhText" v-if="linkName == descriptionsData('中心主任审批').hjmc">*</span>
                                            中心主任审批
                                        </span>
                                        <a-form-item ref="fngksyj" prop="fngksyj" class="zm-form-model">
                                            <div style="width: 100%;" v-if="(descriptionsData('中心主任审批').blzt == '待办' && linkName!=='我的已办') || linkName == '数据修订'">
                                                <reviewOpinions
                                                    ref="reviewOpinionsReffzxzrspyj"
                                                    @getInputOpinion="getInputOpinion"
                                                    @openOpinions="opinions('宣传信息审批',formState.fzxzrspyj,'fzxzrspyj')"
                                                    v-decorator="[
                                                        'fzxzrspyj', { initialValue:formState.fzxzrspyj, rules: rules.fzxzrspyj}
                                                ]"/>
                                                <div  v-if="linkName == '数据修订'" style="text-align: right;">
                                                    <span>办理时间：</span>
                                                    <a-date-picker
                                                        show-time
                                                        :v-model="moment(formState.fksfzrqmsj)"
                                                        :default-value="moment(formState.fksfzrqmsj)"
                                                        :allowClear="false"
                                                        @change="yjTimeChange($event,'fksfzrqmsj')"
                                                    />
                                                </div>
                                            </div>
                                            <div style="width: 100%;" v-else>
                                                <p>{{ formState.fzxzrspyj }}</p>
                                                <div class="yjqm-right-bottom">
                                                    <img v-if="getUrl('中心主任审批')" :src="getUrl('中心主任审批')" alt="" class="yjqmImg"/>
                                                    <span v-else class="yjqmImg">{{ formState.fzxzrspr }}</span>
                                                    <span>{{ formState.fzxzrspsj }}</span>
                                                </div>
                                            </div>
                                        </a-form-item>
                                    </a-descriptions-item>
                                    <a-descriptions-item :span="1" v-if="descriptionsData('信息发布办理').blzt == '已办'">
                                        <span slot="label" class="descriptions-label-slot">
                                            发布日期
                                        </span>
                                        <a-form-item ref="fngksyj" prop="fngksyj" class="zm-form-model">
                                            <div style="width: 100%;" v-if="linkName=='数据修订'">
                                                <a-date-picker
                                                    show-time
                                                    v-model="formState.ffbrq"
                                                    placeholder="请选择发布日期"
                                                />
                                            </div>
                                            <div style="width: 100%;" v-else>
                                                <span>{{ moment(formState.ffbrq).format("YYYY年MM月DD日") }}</span>
                                            </div>
                                        </a-form-item>
                                    </a-descriptions-item>
                                    <a-descriptions-item :span="1" v-if="descriptionsData('信息发布办理').blzt == '已办'">
                                        <span slot="label" class="descriptions-label-slot">
                                            经办人签字
                                        </span>
                                        <a-form-item ref="fngksyj" prop="fngksyj" class="zm-form-model">
                                            <img v-if="getUrl('信息发布办理')" :src="getUrl('信息发布办理')" alt="" class="yjqmImg"/>
                                            <span v-else>{{ formState.fjbrqz }}</span>
                                        </a-form-item>
                                    </a-descriptions-item>
                                    <a-descriptions-item :span="3" v-if="descriptionsData('信息发布办理').hjmc">
                                        <span slot="label" class="descriptions-label-slot">
                                            备&emsp;&emsp;注
                                        </span>
                                        <a-form-item ref="fngksyj" prop="fngksyj" class="zm-form-model">
                                            <div style="width: 100%;" v-if="descriptionsData('信息发布办理').blzt == '待办' && linkName!=='我的已办'">
                                                <a-textarea
                                                    v-if="linkName=='信息发布办理' || linkName == '数据修订'"
                                                    v-model="formState.fbz"
                                                    placeholder="请输入备注:"
                                                    :auto-size="{ minRows: 2}"
                                                />
                                            </div>
                                            <div style="width: 100%;" v-else>
                                                {{ formState.fbz }}
                                            </div>
                                        </a-form-item>
                                    </a-descriptions-item>
                                </a-descriptions>
                            </a-form>
                        </a-spin>
                    </div>
                    <div v-if="summaryActiveKey == '流转记录'" style="padding-top: 30px;">
                        <transferRecords
                            ref="transferRecordsRef"
                            :config="circulationDataTableConfig"
                            @getCirculationQmImg="getCirculationQmImg"/>
                    </div>
                </div>
            </div>
            <template slot="footer">
                <div v-if="linkName == '我的已办'">
                    <a-button class="blue-btn" @click="closeVisible">关闭</a-button>
                </div>
                <div v-else-if="linkName == '数据修订'">
                    <a-button class="blue-btn" @click="updataData">确认修订</a-button>
                </div>
                <div v-else>
                    <a-button @click="onSave('保存')">
                        保存
                    </a-button>
                    <a-button class="blue-btn" @click="onSubmit('提交')">
                        提交
                    </a-button>
                    <a-button v-if="linkName == '中心分管领导审批'" @click="jobTable()" class="blue-btn">
                        跳过单位领导审批,直接发布
                    </a-button>
                    <a-button v-if="linkName !== '申请' || linkName!=='信息发布办理'" class="red-btn" @click="returnClick">
                        退回
                    </a-button>
                </div>
            </template>
        </a-modal>
        <printModal ref="printModalRef" />
    </div>
</template>
<script>
import {
    editFuntion,
    initBzFlow,
    saveFlow,
    submitFlow,
    queryJobByJobId,
    returnUpperzdyFlowJob,
    getMoreUserSignLinkList,
    pidgetlchj,
} from './service/index'
import assessCheckApi from './service/api.js'
import transferRecords from '../modal/transferRecords'
import printModal from '../modal/printModal'
import uploadFilesList from '../modal/uploadFilesList'
import moment from 'moment'
export default {
    components: {
        transferRecords,
        printModal,
        uploadFilesList,
    },
    data() {
        return {
            moment:moment,
            applicationFormVisible: false,
            summaryActiveKey: '申请表',
            aform:this.$form.createForm(this, { name: 'aform' }),
            formState: {},
            circulationDataTableConfig: {
                api: assessCheckApi.flowJkPage,
                rowId: 'id',
                urlType: true,
                paramet:{
                    oaid: ''
                }
            },
            uploadFilesListConfig: {
                isUpload: false,
                fjAddApi: assessCheckApi.initBzFlow,
            },
            rules:{
                fxxmc: [{
                    required: true,
                    message: '请输入信息名称',
                    trigger: 'blur',
                }],
                ffblm: [{
                    required: true,
                    message: '请输入发布栏目',
                    trigger: 'blur',
                }],
                fngksyj: [{
                    required: true,
                    message: '请输入科室领导意见',
                    trigger: 'blur',
                }],
                fbgsyj: [{
                    required: true,
                    message: '请输入办公室意见',
                    trigger: 'blur',
                }],
                fzxfgldspyj: [{
                    required: true,
                    message: '请输入分管领导审批意见',
                    trigger: 'blur',
                }],
                fzxzrspyj: [{
                    required: true,
                    message: '请输入中心主任审批意见',
                    trigger: 'blur',
                }],
            },
            qmImgList: [],
            displayList: [],
            linkName: '申请',
            spinning: false,
        }
    },
    mounted() {
        // this.circulationDataTableConfig.paramet.oaid = '96db3fccad0245df878468d4339f9e5e'
        this.$refs.reviewOpinionsRef= Date.now()
        this.uploadFilesListConfig.isUpload = (this.linkName == '申请' || this.linkName == '数据修订')?true:false
    },
    methods: {
        getInitData(){
            this.formState = {}
            this.summaryActiveKey = '申请表'
        },
        getData(val){
            if(val){
                this.summaryActiveKey = '申请表'
                this.linkName = val.hjmc
                this.uploadFilesListConfig.isUpload = (this.linkName == '申请' || this.linkName == '数据修订')?true:false
                this.formState = {}
                this.formState = {
                    ...val.oaMap,
                    jobid: val.jobMap?val.jobMap.id:''
                }
                if(this.formState.ffbrq){
                    let nian = this.formState.ffbrq.substr(0,4)
                    let yue = this.formState.ffbrq.substr(5,2)
                    let ri = this.formState.ffbrq.substr(8,2)
                    this.formState.ffbrq = nian + '-' + yue + '-' + ri
                }
                this.formState.ffbrq = this.formState.ffbrq?moment(this.formState.ffbrq):null
                //console.log('发布日期',this.formState.ffbrq)
                //console.log('发布日期1',moment(this.formState.ffbrq).format("YYYY年MM月DD日"))
                //console.log('发布日期2',moment(this.formState.ffbrq).format("YYYY-MM-DD"))
                this.circulationDataTableConfig.paramet.oaid = this.formState.id
                this.qmImgList = []
                this.displayList = []
                this.getDisplayList()
            }
        },
        getDisplayList(){
            pidgetlchj({pid:this.formState.id}).then((res) => {
                let arr1 = res.result
                this.displayList = []
                this.displayList = res.result

                if(this.linkName == '数据修订'){
                    const index = this.displayList.findIndex((item) => item.blzt == '待办');
                    if (index !== -1) {
                        this.displayList.splice(index, 1);
                    }
                    //console.log('this.displayList',this.displayList)
                }

                arr1.forEach(async item => {
                    if(item.blrid && item.blzt!=='待办'){
                        let resa = await getMoreUserSignLinkList({ids:item.blrid})
                        if(resa.success && resa.result.length){
                            if(resa.result[0].signLink == ''){
                                // //console.log('没有获得图片 signLink == 0')
                                this.qmImgList.push({
                                    hjmc: item.hjmc,
                                    url: null
                                })
                            } else {
                                this.qmImgList.push({
                                    hjmc: item.hjmc,
                                    url: resa.result[0].signLink+'&aa='+Date.now()
                                })
                                // //console.log('获得的签名图片列表',this.qmImgList)
                            }
                        } else {
                            // //console.log('没有获得图片')
                        }
                    } else {}
                })
                // //console.log('最终获得的签名图片列表---',this.qmImgList)
            })
        },
        closeVisible(){
            this.applicationFormVisible = false
            this.$emit('success')
        },
        summaryActiveChange(val){
            //console.log(val)
        },
        emitFormid(val){
            this.formState = {
                jobid:val.jobMap.id,
                ...val.oaMap
            }
            //console.log('formState===',this.formState)
        },
        getCirculationQmImg(item1,item2){
            // //console.log('-----?????-----',item1,item2)
            this.qmImgList = []
            this.displayList = []
            this.qmImgList = item1
            this.displayList = [...item2]
            // //console.log('111111111',this.qmImgList)
            // //console.log('222222222',this.displayList)
        },
        getUrl(hjmcName){
            let url = ''
            // //console.log('没有？？？',this.qmImgList)
            this.qmImgList.forEach(item => {
                // //console.log(hjmcName,item)
                if(item.hjmc == hjmcName){
                    url = item.url
                }
            })
            // //console.log(hjmcName,url)
            return url
        },
        descriptionsData(hjmc){
            let data = {}
            this.displayList.forEach(item => {
                // //console.log('descriptionsData000',hjmc,item)
                if(item.hjmc == hjmc){
                    data = {...item}
                }
            })
            // //console.log('descriptionsData',data)
            return data
        },
        getInputOpinion(val,valueData){
            //console.log(val,valueData)
            let data = this.formState
            data[valueData.hjmc] = val
            this.aform.setFieldsValue({
                fngksyj: this.formState.fngksyj,
                fbgspcyj: this.formState.fbgspcyj,
                fzxfgldspyj: this.formState.fzxfgldspyj,
                fzxzrspyj: this.formState.fzxzrspyj
            });
        },
        opinions(val1,val2,val3){
            //console.log(val1,val2,val3)
            this.$refs[`reviewOpinionsRef${val3}`].getData({opinionType:val1,oldVal:val2,valueData:{hjmc:val3}})
        },
        onSave(){
            let data = {}
            let sdata = {
                jobid: this.formState.jobid,
                oaid: this.formState.id,
                map: {},
                opinion: '',
            }
            //console.log('riqi',this.formState.ffbrq)
            if(this.linkName == '申请'){
                data = {
                    fxxmc: this.formState.fxxmc,
                    ffblm: this.formState.ffblm,
                    flmnr: this.formState.flmnr,
                    id: this.formState.id?this.formState.id:''
                }
                sdata.map = {
                    ...data
                }
                this.formState.id?this.saveFlowFuntion(sdata):this.initBzFlowFuntion(data)
            } else if(this.linkName == '科室审批'){
                sdata.map = {
                    fksfzr: this.formState.fksfzr,
                    fngksyj: this.formState.fngksyj,
                    fksfzrsj: this.formState.fksfzrsj,
                }
                sdata.opinion = this.formState.fngksyj,
                this.saveFlowFuntion(sdata)
            }else if(this.linkName == '办公室审批'){
                sdata.map = {
                    fbgsfzr: this.formState.fbgsfzr,
                    fbgsyj: this.formState.fbgsyj,
                    fbgsfzrsj: this.formState.fbgsfzrsj,
                }
                sdata.opinion = this.formState.fbgsyj,
                this.saveFlowFuntion(sdata)
            } else if(this.linkName == '中心分管领导审批'){
                sdata.map = {
                    fzxfgldspyj: this.formState.fzxfgldspyj,
                    fzxfgldr: this.formState.fzxfgldr,
                    fzxfgldrsj: this.formState.fzxfgldrsj,
                }
                sdata.opinion = this.formState.fzxfgldspyj,
                this.saveFlowFuntion(sdata)
            } else if(this.linkName == '中心主任审批'){
                sdata.map = {
                    fzxzrspyj: this.formState.fzxzrspyj,
                    fzxzrspr: this.formState.fzxzrspr,
                    fzxzrspsj: this.formState.fzxzrspsj,
                }
                sdata.opinion = this.formState.fzxzrspyj,
                this.saveFlowFuntion(sdata)
            } else if(this.linkName == '信息发布办理'){
                sdata.map = {
                    // ffbrq: this.formState.ffbrq?moment(this.formState.ffbrq).format("YYYY年MM月DD日"):null,
                    fjbrqz: this.formState.fjbrqz,
                    fbz: this.formState.fbz
                }
                sdata.opinion = '同意',
                this.saveFlowFuntion(sdata)
            }
        },
        onSubmit(){
            this.aform.validateFields((err, values) => {
                if (!err) {
                    var that = this
                    that.$confirm({
                        title: '您确定要提交吗?',
                        onOk() {
                            let data = {
                                jobid: that.formState.jobid,
                                oaid: that.formState.id,
                                map: {},
                                opinion: '',
                            }
                            if(that.linkName == '申请'){
                                data.map = {
                                    fxxmc: that.formState.fxxmc,
                                    ffblm: that.formState.ffblm,
                                    flmnr: that.formState.flmnr,
                                    id: that.formState.id?that.formState.id:'',
                                    fsffqlc: that.formState.id?'':'是',
                                }
                                that.formState.id?that.submitFlowFuntion(data):that.initBzFlowFuntion(data.map,'1')
                            } else if(that.linkName == '科室审批'){
                                data.map = {
                                    fksfzr: that.formState.fksfzr,
                                    fngksyj: that.formState.fngksyj,
                                    fksfzrsj: that.formState.fksfzrsj,
                                }
                                data.opinion = that.formState.fngksyj,
                                that.submitFlowFuntion(data)
                            } else if(that.linkName == '办公室审批'){
                                data.map = {
                                    fbgsfzr: that.formState.fbgsfzr,
                                    fbgsyj: that.formState.fbgsyj,
                                    fbgsfzrsj: that.formState.fbgsfzrsj,
                                }
                                data.opinion = that.formState.fbgspcyj,
                                that.submitFlowFuntion(data)
                            } else if(that.linkName == '中心分管领导审批'){
                                data.map = {
                                    fzxfgldspyj: that.formState.fzxfgldspyj,
                                    fzxfgldr: that.formState.fzxfgldr,
                                    fzxfgldrsj: that.formState.fzxfgldrsj,
                                }
                                data.opinion = that.formState.fzxfgldspyj,
                                that.submitFlowFuntion(data)
                            } else if(that.linkName == '中心主任审批'){
                                data.map = {
                                    fzxzrspyj: that.formState.fzxzrspyj,
                                    fzxzrspr: that.formState.fzxzrspr,
                                    fzxzrspsj: that.formState.fzxzrspsj,
                                }
                                data.opinion = that.formState.fzxzrspyj,
                                that.submitFlowFuntion(data)
                            } else if(that.linkName == '信息发布办理'){
                                data.map = {
                                    ffbrq: that.formState.ffbrq?moment(that.formState.ffbrq).format("YYYY年MM月DD日"):moment().format("YYYY年MM月DD日"),
                                    fjbrqz: that.formState.fjbrqz,
                                    fbz: that.formState.fbz
                                }
                                data.opinion = '同意',
                                // //console.log('------',that.formState.ffbrq,moment().format("YYYY年MM月DD日"),data.map)
                                that.submitFlowFuntion(data)
                            }
                        },
                        onCancel() {},
                    });
                }
            })
        },
        initBzFlowFuntion(data,type){
            initBzFlow(data).then(res => {
                if(res.code == 200){
                    this.$message.success(res.message)
                    this.formState = {}
                    this.formState = {
                        ...res.result.oaMap,
                        jobid: res.result.jobMap.id
                    }
                    // this.formState.fjbzbksrq = moment(this.formState.fjbzbksrq)
                    // this.formState.fjbzbjsrq = moment(this.formState.fjbzbjsrq)
                    if(type){
                        this.closeVisible()
                    }
                } else {
                    this.$message.warning(res.message)
                }
                this.loading = false
            })
        },
        saveFlowFuntion(data){
            this.spinning = true
            saveFlow(data).then(res => {
                if(res.code == 200){
                    this.$message.success(res.message)
                } else {
                    this.$message.warning(res.message)
                }
                this.spinning = false
            })
        },
        submitFlowFuntion(data){
            this.spinning = true
            submitFlow(data).then(res => {
                if(res.code == 200){
                    this.$message.success(res.message)
                    this.closeVisible()
                } else {
                    this.$message.warning(res.message)
                }
                this.spinning = false
            })
        },
        // 跳过单位领导审批,直接发布
        jobTable(){
            this.aform.validateFields((err, values) => {
                if (!err) {
                    var that = this
                    that.$confirm({
                        title: '您确定要跳过单位领导审批,直接发布吗?',
                        onOk() {
                            let data = {}
                            data = {
                                jobid: that.formState.jobid,
                                oaid: that.formState.id,
                                map: {
                                    fzxfgldr: that.formState.fzxfgldr,
                                    fzxfgldspyj: that.formState.fzxfgldspyj,
                                    fzxfgldrsj: that.formState.fzxfgldrsj,
                                },
                                opinion: that.formState.fzxfgldspyj,
                                nextNode: '信息发布办理',
                            }
                            submitFlow(data).then(res => {
                                if(res.code == 200){
                                    that.$message.success(res.message)
                                    that.closeVisible()
                                } else {
                                    that.$message.warning(res.message)
                                }
                            })
                        },
                        onCancel() {},
                    });
                }
            })
        },
        // 退回
        returnClick(){
            this.aform.validateFields((err, values) => {
                if (!err) {
                    var that = this
                    that.$confirm({
                        title: '您确定要退回吗?',
                        onOk() {
                            that.spinning = true
                            queryJobByJobId({jobid:that.formState.jobid}).then(res => {
                                let list = res.result.jobHistoryList
                                let slist = list.filter(item => item.fhjmc == '申请')
                                const sortedDates = slist.sort((a, b) => new Date(b) - new Date(a));
                                that.returnFuntion(that.formState.jobid,sortedDates[slist.length - 1].id)
                            })
                        },
                        onCancel() {},
                    })
                }
            })
        },
        returnFuntion(jobid,ids){
            let returnStr = ''
            if(this.linkName == '申请'){
                returnStr = this.formState.fksshyj
            } else if(this.linkName == '科室审批'){
                returnStr = this.formState.fngksyj
            } else if(this.linkName == '中心分管领导审批'){
                returnStr = this.formState.fzxfgldspyj
            } else if(this.linkName == '中心主任审批'){
                returnStr = this.formState.fzxzrspyj
            }
            let data = {
                jobid: jobid,
                opinion: returnStr,
                shjid: ids,
                lcmbbm: '',
                smgflag: '',
                smsContent: '',
            }
            returnUpperzdyFlowJob(data).then(res => {
                if(res.code == 200){
                    this.$message.success(res.message)
                    this.closeVisible()
                } else {
                    this.$message.error(res.message)
                }
                this.spinning = false
            })
        },
        printClick(type,value,qmValue){
            this.$refs.printModalRef.modalClick(type,value,qmValue)
        },
        yjTimeChange(val,name){
            let data = this.formState
            data[name] = moment(val).format('YYYY-MM-DD HH:mm:ss')
        },
        updataData(){
            var that = this
            that.$confirm({
                title: '您确定修改当前表单数据吗?',
                onOk() {
                    let data = {
                        id: that.formState.id,
                        fxxmc: that.formState.fxxmc,
                        ffblm: that.formState.ffblm,
                        flmnr: that.formState.flmnr,
                        fngksyjqm: that.formState.fngksyjqm,
                        fngksyjqmsj: that.formState.fngksyjqmsj,
                        fngksyj: that.formState.fngksyj,
                        fbgspcyj: that.formState.fbgspcyj,
                        fbgspcyjr: that.formState.fbgspcyjr,
                        fbgspcyjsj: that.formState.fbgspcyjsj,
                        fzxfgldspyj: that.formState.fzxfgldspyj,
                        fzxfgldr: that.formState.fzxfgldr,
                        fzxfgldrsj: that.formState.fzxfgldrsj,
                        fzxzrspyj: that.formState.fzxzrspyj,
                        fzxzrspr: that.formState.fzxzrspr,
                        fzxzrspsj: that.formState.fzxzrspsj,
                    }
                    //console.log(data)
                    that.spinning = true
                    editFuntion(data).then(res => {
                        if(res.code == 200){
                            that.$message.success(res.message)
                        } else {
                            that.$message.warning(res.message)
                        }
                        that.spinning = false
                    })
                },
                onCancel() {
                    //console.log('Cancel');
                },
            });
        },
    }
}
</script>
<style>
@import url('../css/oaLess.css');
</style>
